<input type="hidden" id="tid" value="<?= $tid ?>"/>

<!--主体部分-->
<section class="main">
    <div class="main-inner">
        <div class="bs-cont home">
            <section class="bc-middle mt15 clearfix">
                <!--左侧信息-->
                <div class="qb-left plan2 bor fl">
                    <p class="title2 white txt-center">
                        <?php if ($tid == 1): ?>
                            重庆时时彩历史数据
                        <?php elseif ($tid == 2): ?>
                            北京pk10历史数据
                        <?php elseif ($tid == 3): ?>
                            广东11选5历史数据
                        <?php elseif ($tid == 4): ?>
                            江西11选5历史数据
                        <?php elseif ($tid == 5): ?>
                            山东11选5历史数据
                        <?php endif; ?>
                    </p>
                    <ul class="bl-item"> 
                        <li>
                            <span>历史期号</span>
                            <span>开出号码</span>
                        </li>

                    </ul>
                    <div class="kj4">
                        <ul class="bl-item2 opencode_history">
                        </ul>
                    </div>
                </div>
                <!--右侧信息-->
                <div class="qb-right plan bor fl">
                    <div class="br-item br-item0">
                        <!--标题栏-->
                        <div class="title txt-cnt">
                            <?php if ($tid == 1): ?>
                            重庆时时彩 - 五码三期 - 历史计划查询
                        <?php elseif ($tid == 2): ?>
                            北京pk10 - 五码三期 - 历史计划查询
                        <?php elseif ($tid == 3): ?>
                            广东11选5 - 一码三期 - 历史计划查询
                        <?php elseif ($tid == 4): ?>
                            江西11选5 - 一码三期 - 历史计划查询
                        <?php elseif ($tid == 5): ?>
                            山东11选5 - 一码三期 - 历史计划查询
                        <?php endif; ?>
                            重庆时时彩 - 预测5数追号3期 - 历史计划查询
                        </div>
                        <div class="plan-time fs18">
                            <div class="plan-nav">

                                <?php foreach ($planer as $k => $rows): ?>
                                    <span <?php if ($k == $planer_tid): ?>class="cur"<?php endif; ?> planer_tid="<?= $k ?>"><?= $rows ?></span>
                                <?php endforeach; ?>
                            </div>
                            <div class="plan-times">
                                查询日期:<input type="text" class="demo-input laydate-input" placeholder="请选择查询日期" id="datetime" value="<?=$query_date?>">
                            </div>
                        </div>
                    </div>
                    <div class="br-item br-item0">
                        <section class="qb1" >
                            <div class="qb3 clearfix"> 
                                <ul class="list borBottom plancode_history">
                                </ul>
                            </div>
                        </section>
                    </div>
                </div>
            </section>
        </div>
    </div>
</section>
</body>
</html>
<script src="<?= base_url() ?>static/home/laydate/laydate.js"></script>
<script>

    $(function () {
        var datetime = $("#datetime").val();
        var planer_tid = <?=$planer_tid?>;
        
        let lottery_type_id = $("#tid").val();
        
        
        getOpencode(lottery_type_id);
        getPlancode(lottery_type_id,planer_tid,datetime);

        laydate.render({
            elem: '#datetime'
            , max: "<?= date('Y-m-d') ?>"
            , done: function (value) {
                datetime = value;
                getPlancode(lottery_type_id,planer_tid,value);
            }
        });


        $(".plan-nav span").click(function () {
            $(this).addClass('cur').siblings().removeClass('cur');
            planer_tid = $(this).attr('planer_tid');
            getPlancode(lottery_type_id,planer_tid,datetime);
        })




    })
    function getOpencode(tid) {
        let url = "<?= site_url('plan/getOpencode') ?>";
        let jsonData = {
            'tid': tid
        };
        $.get(url, jsonData, function (redata) {
            let str = '';
            for (x in redata.opencode) {
                str += '<li><span>' + redata.opencode[x].issue + '</span><span>' + redata.opencode[x].opencode + '</span></li>';
            }
            $(".opencode_history").html(str);
            setTimeout(getOpencode,30000,tid);
        }, 'json');
    }

    function getPlancode(lottery_type_id,planer_tid,query_date) {
        let url = "<?= site_url('plan/showPlancodeByDate') ?>";
        let jsonData = {
            'tid': lottery_type_id,
            'planer_tid': planer_tid,
            'query_date': query_date
        };
        $.get(url, jsonData, function (redata) {
            let str = '';
            if (redata.plancode.length == 0) {
                str = '抱歉,查询日期暂时没有数据哦!'
            } else {
                for (x in redata.plancode) {
                    let resultstr = '';
                    if (redata.plancode[x].is_hit == 1) {
                        resultstr = '中' + redata.plancode[x].hit_index;
                    } else {
                        resultstr = '挂';
                    }
                    str += '<li class="black">' + redata.plancode[x].plan_issue + '<i class="lines"></i>' + redata.planername + '<i class="lines"></i>' + redata.plancode[x].current_issue + '期  <i class="lines"></i><' + redata.plancode[x].plan_code + '><i class="lines"></i>' + resultstr + '</li>';
                }
            }
            $(".plancode_history").html(str);
            setTimeout(getPlancode,30000,lottery_type_id,planer_tid,query_date);
        }, 'json');

    }
</script>

